package puyu.manage.service.utils;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;

/**
 * 文件工具类
 */
public class FileUtils{

    public static final String RIGHT = "right";

    public static final String LEFT = "left";


    /**
     * 图片向左旋转90度
     * originalImage 图像
     * format = right向右旋转90°
     * format = left向左旋转90°
     */
    public static  BufferedImage rotateImage(BufferedImage originalImage,String format) {
        int width = originalImage.getWidth();
        int height = originalImage.getHeight();
        BufferedImage rotatedImage = new BufferedImage(height, width, originalImage.getType());
        Graphics2D g2d = rotatedImage.createGraphics();
        g2d.translate((height - width) / 2, (width - height) / 2);
        if (LEFT.equals(format)){
            g2d.rotate(-Math.PI / 2, height / 2, width / 2);
        }else {
            g2d.rotate(Math.PI / 2, height / 2, width / 2);
        }
        g2d.drawRenderedImage(originalImage, null);
        g2d.dispose();
        return rotatedImage;
    }




}
